package com.albert.order.entry;

import java.util.Objects;

/**
 * @author yangjunwei
 * @date 2021/7/3 上午12:40
 */
public enum  OrderTypeEnum {
    ORDINARY_ORDER(1,"普通订单",60000L),
    PEAK_ORDER(2,"高峰订单",30000L),;

    /**
     * 订单类型
     */
    private Integer orderType;
    /**
     * 订单类型名称
     */
    private String orderTypeName;
    /**
     * 限时支付时间(s)
     */
    private Long timeLimitValue;

    OrderTypeEnum(Integer orderType, String orderTypeName, Long timeLimitValue) {
        this.orderType = orderType;
        this.orderTypeName = orderTypeName;
        this.timeLimitValue = timeLimitValue;
    }

    public static Long getTimeLimitValueByOrderType(Integer orderType){
        OrderTypeEnum[] orderTypeEnums = OrderTypeEnum.values();
        for (OrderTypeEnum orderTypeEnum : orderTypeEnums) {
            if(Objects.equals(orderTypeEnum.orderType,orderType)){
                return orderTypeEnum.timeLimitValue;
            }
        }
        return -1L;
    }
}
